<%-- 
    Document   : UpdateHarga2.jsp
    Created on : Dec 10, 2013, 8:55:23 PM
    Author     : Bimo
--%>

<%@page import="koneksi.CekKoneksi"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head><script>function validate(evt) {
        var theEvent = evt || window.event;
        var key = theEvent.keyCode || theEvent.which;
        key = String.fromCharCode(key);
        var regex = /[0-9\b\t]|\./;
        if (!regex.test(key)) {
            theEvent.returnValue = false;
            if (theEvent.preventDefault)
                theEvent.preventDefault();
        }
    }</script> 
    <body>
        <%

            String kodB = request.getParameter("kodeB");

            Connection con = koneksi.CekKoneksi.open();
            Statement stat = con.createStatement();
            ResultSet rs = null;
            String in1 = null;


            rs = stat.executeQuery("SELECT kode_barang,jumlah,nama_barang,harga_barang FROM cabanga where"
                    + " kode_barang='" + kodB + "' "
                    + "UNION SELECT kode_barang,jumlah,nama_barang,harga_barang FROM cabangb where"
                    + " kode_barang='" + kodB + "' "
                    + "Union SELECT kode_barang,jumlah,nama_barang,harga_barang FROM cabangc where"
                    + " kode_barang='" + kodB + "' ");

            if (rs.next()) {
                String kodebarang = rs.getString("kode_barang");
                String namabarang = rs.getString("nama_barang");
                String hargabarang = rs.getString("harga_barang");
                String jumlah = rs.getString("jumlah");




        %>
    <center> <h2>UPDATE HARGA </h2></center>
    <form name="ingredient" id="ingredient"  action="kontrolUpdate"   >
        <table width="332" height="252" border="0" align="center" cellpadding="2" cellspacing="2">



            <tr>
                <th height="33" colspan="2"><div align="center">        </div></th>
            </tr>
            <tr>
                <th>Kode Barang </th>
                <td><input name="kodeBarang" readonly="" type="text"  class="text" id="kodeBarang" value="<%=kodB%>" /></td>

            </tr>
            <tr>
                <th>Nama Barang </th>
                <td><input name="namaBarang" readonly="" type="text" class="text" id="namaBarang" value="<%=namabarang%>" /></td>
            </tr>
            <tr>
                <th>Stock</th>
                <td><input name="stockBarang" readonly="" type="text" class="text" id="stockBarang" value="<%=jumlah%>" /></td>
            </tr> 
            <tr>
                <th>Harga Lama</th>
                <td><input name="harga" readonly="" type="text" class="text" id="stockBarang" value="<%= hargabarang%>" /></td>
            </tr>
            <tr>
                <th>Harga Update </th>
                <td><input name="hargaBarang2" type="text" id="hb" class="text" onkeypress='validate(event)' /></td>
            </tr>
            <tr>     

                <%}
                    con.close();%>

                <td class="submission" colspan="6">
                    <button type="submit"  >UPDATE</button>
                </td>
            </tr>  </form>
    <tr>
        <th class="submission" colspan="2"><div align="center"><a href="TableUpdate.jsp">Halaman Update Harga</a> </div></th>
</tr>
</table>


</body>
</html>